//
//  MyTableViewController.m
//  13-AutoLayout强化
//
//  Created by dllo on 16/8/1.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MyTableViewController.h"
#import "MyTableViewCell.h"
#define Ktable @"reuseIdentifier"
@interface MyTableViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) NSArray *array;
@end

@implementation MyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
    NSString *str = @"念、不忘初心，愿意全身心地投入，博取一个不确定的未来，我们有什么理由不为他们点赞呢？  我们注意到，一些创业者或者投资人，似乎并不喜欢“连续创业者”这样的称谓，仅仅因为他们觉得，这似乎意味着失败，代表了“你不行”。他们更看重的是那种连续的“成功创业者”。的确，";
    NSString *str1 = @"续的冒险精神和创新能力，无论是连续的成功或者曾经历失败之后的坚持，他们改变着自己，也改变着他们和我们共同";
    NSString *str2 = @"的问题上达成共识，但在中美存在争议的议题上，预计习近平不会做出什么让步。这些问题包括网络间谍、在南海争议";
    _array = @[str,str1,str2];
//    自定义cell self-sizing iOS 8以后用 7不能用
//    效率低，系统计算
//预估高度
    self.tableView.estimatedRowHeight = 40;
//    高度自动计算高度
    self.tableView.rowHeight = UITableViewAutomaticDimension;
//    根据label内容，计算高度，并赋予tableview
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _array.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
    
    // Configure the cell...
    MyTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:Ktable];
    cell.textLabel.text = _array[indexPath.row];
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
